<template>
  <div class="login">
    <header>
      <img src="../../public/1.png" alt="" />
    </header>
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="用户名"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="密码"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div class="box">
        <p>找回密码</p>
        <p></p>
        <p @click="$router.push('register')">注册/验证码登录</p>
      </div>
      <div style="margin: 16px">
        <van-button
          round
          block
          color="linear-gradient(to right, #ff6034, #fc5500)"
          native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
    <!-- 第三方登录 -->
    <div class="third">
      <p class="chirdp">第三方登录</p>
      <ul>
        <li><i class="iconfont icon-weixin"></i>微信登录</li>
        <li><i class="iconfont icon-qq"></i>QQ登陆</li>
      </ul>
    </div>
  </div>
</template>

<script>
import { Field, Form, Button, Toast } from "vant";
import { login } from "../request/http";
export default {
  name: "login",
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    onSubmit(values) {
      console.log("submit", values);
      login({
        mobile: this.username,
        type: 1,
        client: 1,
        password: this.password,
      }).then((res) => {
        console.log(res);
        this.$router.push("/mine");
        localStorage.setItem("adminToken", res.remember_token);
      });
    },
  },
  created() {},
  mounted() {},
  components: {
    [Field.name]: Field,
    [Form.name]: Form,
    [Button.name]: Button,
    [Toast.name]: Toast,
  },
  computed: {},
  watch: {},
};
</script>

<style lang='scss' scoped>
.mine {
  background-color: #fff;
  height: 100vh;
}
header {
  width: 100%;
  text-align: center;
  img {
    width: 80%;
    margin: 80px 0;
  }
}
.van-form {
  box-sizing: border-box;
  width: 100%;
  padding: 0 20px;
  .box {
    display: flex;
    justify-content: space-around;
    p {
      flex: 1;
      text-align: center;
      color: #999999;
      font-size: 0.35rem;
    }
  }
}
.third {
  .chirdp {
    text-align: center;
  }
  ul {
    display: flex;
    li {
      flex: 1;
      text-align: center;
      font-size: 18px;
      i {
        margin-right: 10px;
      }
    }
    li:nth-child(1) i {
      color: #78c660;
      font-size: 26px;
    }
    li:nth-child(2) i {
      color: #87ccfa;
      font-size: 26px;
    }
  }
}
</style>